<?php

namespace app\common\model;

/**
 * [Ilike  寺院关注表]
 * @author [C。]
 * @return html
 */
class Ilike extends Base
{
    protected $name = 'ilike';
    /**
     * 根据搜索条件获取寺院列表信息
     */
    public function getlist($map,$from = 0, $size = 5,$field = '*')
    {
        $order = ['i.id' => 'desc'];
        $join = [
            ['app_company c','c.id = i.itemid'],
        ];
        $result =  $this->field($field)
            ->alias('i')
            ->join($join)
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();

        return $result;
    }

    /**
     * 搜索获取寺院列表总数
     * @param array $param
     */
    public function getCount($map) {
        $join = [
            ['app_company c','c.id = i.itemid'],
        ];
        return $this
            ->alias('i')
            ->join($join)
            ->where($map)
            ->count();
    }
    /**
     * [findData  根据comid和memid获取信息]
     * @author [C。]
     * @param string $id
     * @return array
     */
    public function findDataByComid($map)
    {
        return  $this->where($map)->find();
    }
    /**
     * 根据搜索条件获取列表信息
     */
    public function getLists($map, $from=0, $size = 5)
    {
        $order = ['i.id' => 'desc'];
        $join = [
            ['app_member am','am.id = i.memid'],
        ];
        $result =  $this->field('am.id,am.tel,am.username,am.sex,am.city,am.bathday,am.zid,am.addtime')
            ->alias('i')
            ->join($join)
            ->where($map)
            ->limit($from, $size)
            ->order($order)
            ->select();

        return $result;
    }
    /**
     * 根据条件来获取列表的数据的总数
     * @param array $param
     */
    public function getCounts($map = []) {
        $join = [
            ['app_member am','am.id = i.memid'],
        ];
        $result =  $this->alias('i')
            ->join($join)
            ->where($map)
            ->count();

        return $result;
    }
}